home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / tools / xmstrix.com / HICOPY2.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-11-02  |  2.7 KB  |  116 lines

  1. ;filename HICOPY2.ASM - file to test copying of a block of
  2. ; code into the HMA from conventional memory, then branch
  3. ; to, execute and return from that code.
  4. ;Released into the Public Domain - November/88 by D. Roy
  5.  
  6. CODE        SEGMENT PARA PUBLIC 'CODE'
  7.         ASSUME    CS:CODE, DS:CODE ;-----------------------------;
  8.         ORG    100H         ;COM file format! Remember to ;
  9.                      ; use EXE2BIN                 ;
  10. START:                     ;-----------------------------;
  11.     JMP    XMSTEST
  12. ;data area
  13. COPY_CODE    LABEL    BYTE
  14.     LEA    DX,HI_MSG
  15.     MOV    AH,9
  16.     INT    21h
  17.     RETF
  18.     HI_MSG        DB    'Hello, World! HMA here...$'
  19. COPY_END    LABEL    BYTE
  20. XMSControl    DD    ?
  21. HMAStart    DD    ?
  22. NODRIVER_MSG    DB    'No XMS driver installed!...$'
  23. BADVERS_MSG    DB    'Requires Version 2.X XMS Driver!...$'
  24. NOHMA_MSG    DB    'HMA denied!...$'
  25. OKHMA_MSG    DB    'HMA successfully allocated!',10,13,'$'
  26. NOA20_MSG    DB    'A20 Line not enabled!$'
  27. A20LINE_MSG    DB    'A20 Line enabled...',10,13,'$'
  28. COPY_MSG    DB    'Copying...$'
  29. COMPLETE_MSG    DB    'complete.',10,13,'$'
  30.  
  31. ;code area
  32. XMSTEST:
  33.     MOV    AX,4300h
  34.     INT    2Fh
  35.     CMP    AL,80h
  36.     LEA    DX,NODRIVER_MSG
  37.     JE    XM1
  38.     JMP    ERROR_EXIT
  39. ;get address of control driver function
  40. XM1:    MOV    AX,4310h
  41.     INT    2Fh
  42.     MOV    WORD PTR [XMSControl],BX
  43.     MOV    WORD PTR [XMSControl+2],ES
  44. ;hard load the HMA starting address (doesn't change)
  45.     MOV    WORD PTR [HMAStart],0010h
  46.     MOV    WORD PTR [HMAStart+2],0FFFFh
  47. ;get driver's version number
  48.     MOV    AH,00
  49.     CALL    [XMSControl]
  50.     CMP    AH,2
  51.     LEA    DX,BADVERS_MSG
  52.     JNE    ERROR_EXIT
  53. ;now request an HMA
  54.     MOV    AH,01
  55.     MOV    DX,0FFFFh    ;since we're an application
  56.     CALL    [XMSControl]
  57. ;and verify allocation
  58.     OR    AX,AX
  59.     LEA    DX,NOHMA_MSG
  60.     JE    ERROR_EXIT
  61.     LEA    DX,OKHMA_MSG
  62.     CALL    WRITE_STRING
  63. ;now, enable the A20 address line
  64.     MOV    AH,3
  65.     CALL    [XMSControl]
  66.     OR    AX,AX
  67.     LEA    DX,NOA20_MSG
  68.     JE    ERROR_EXIT
  69.     LEA    DX,A20LINE_MSG
  70.     CALL    WRITE_STRING
  71. ;OK, let's do a block copy to the HMA
  72.     LEA    DX,COPY_MSG        ;say what we're up to
  73.     CALL    WRITE_STRING
  74.     CLD                ;direction forward
  75.     PUSH    SI            ;save what we're using
  76.     PUSH    DI
  77.     PUSH    ES
  78.     MOV    CX,OFFSET COPY_END    ;end of data
  79.     SUB    CX,OFFSET COPY_CODE    ;start of data
  80.     SHR    CX,1            ;divide by 2 for words
  81.     LEA    SI,COPY_CODE        ;point to source
  82.     MOV    BX,0FFFFh        ;segment of HMA
  83.     MOV    ES,BX            ; into ES
  84.     MOV    DI,0010h        ;point to offset
  85. L1:    MOVSW                ;moving words is faster
  86.     LOOP    L1            ;loop until done
  87.     POP    ES            ;housecleaning
  88.     POP    DI
  89.     POP    SI
  90. ;and signal completion
  91.     LEA    DX,COMPLETE_MSG
  92.     CALL    WRITE_STRING
  93. ;activate HMA resident code
  94.     CALL    [HMAStart]
  95. ;finally, disable the A20 address line
  96.     MOV    AH,4
  97.     CALL    [XMSControl]
  98. ;and release the HMA
  99.     MOV    AH,2
  100.     CALL    [XMSControl]
  101.     JMP    EXIT
  102. ERROR_EXIT:
  103.     CALL    WRITE_STRING
  104. EXIT:    INT    20h
  105.  
  106. ;-- subroutines ---------------
  107.  
  108. WRITE_STRING    PROC    NEAR
  109.     MOV    AH,9
  110.     INT    21h
  111.     RET
  112. WRITE_STRING    ENDP
  113.  
  114. CODE        ENDS
  115.     END    START
  116.